package com.njxxted.activiti.common.listener.process;

import com.njxxted.activiti.common.util.ContextFactoryUtil;
import com.njxxted.activiti.modules.process.defintion.dao.ActRunDefinitionDao;
import org.activiti.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 描述：流程结束执行监听器
 * <p>
 * 作者：Ostrich Hu
 * 时间：2019/11/27 16:16 星期三
 */
public class ProcessEndExecutionListener extends BaseTemplateExecutionListener {

    private static final long serialVersionUID = 5811890606119792169L;

    @Override
    protected void execute(DelegateExecution execution, String processDefinitionId, String activityId) {
        logger.debug("流程[{}]结束执行监听器", execution.getProcessInstanceId());
        ActRunDefinitionDao actRunDefinitionDao = (ActRunDefinitionDao) ContextFactoryUtil.getBean("actRunDefinitionDao");
        if (null != actRunDefinitionDao) {
            //根据流程实例id删除运行时流程配置信息
            actRunDefinitionDao.deleteByInstanceId(execution.getProcessInstanceId());
        }
    }

    @Override
    protected Integer getScriptType() {
        return null;
    }
}
